package com.demo.miaosha.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.demo.miaosha.Entity.User;
import com.demo.miaosha.Mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * UserService
 *
 * @blame 吴经纶
 */
@Service
public class UserService {
    @Resource
    private UserMapper userMapper;
    public boolean insertUser(String name){
        int result = userMapper.insert(User.builder().name(name).build());
        System.out.println(result);
        return result != 0;
    }
    public User findUser(String name){
        Map<String,Object> map = new HashMap<>(4);
        map.put("name",name);
        List<User> result = userMapper.selectByMap(map);
        return result.get(0);
    }

}
